package com.awspaas.user.apps.processforsap.event;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst;
import com.actionsoft.sdk.local.SDK;

import java.util.List;

public class MMFormAfterSaveForCEI extends ExecuteListener {
    @Override
    public void execute(ProcessExecutionContext param) throws Exception {//BO表名
        String boName = param.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BONAME);
        BO formData = (BO) param.getParameter(ListenerConst.FORM_EVENT_PARAM_FORMDATA);
        if (boName.equals("BO_EU_SAP_CCST")){
            String shelfLife= formData.getString("SHELF_LIFE");
            List<BO> list = SDK.getBOAPI().query(boName).bindId(formData.getBindId()).list();
            for (BO bo:list){
                bo.set("SHELF_LIFE",shelfLife);
                SDK.getBOAPI().update(boName,bo);
            }
        }
    }
}
